If you're a C or C++ programmer, you'll need to understand some of the key terms in the Java programming language before proceeding with the QuickTime for Java API.
In Java, you can think of an object as a collection of data values, or fields. In addition, there are methods that operate on that data. The data type of an object is called a class; and an object is referred to as an instance of its class. In object-oriented programming, the class defines the type of each field in the object. The class also provides the methods that operate on data that is contained in an instance of the class. You create an object using the new keyword. This invokes a constructor method of the class to initialize the new object. You access the fields and methods of an object by using the dot ( . ) operator.
In Java, methods that operate on the object itself are known as instance methods. These are different from the class methods. Class methods are declared static , and they operate on the class itself rather than on an individual instance of the class. The fields of a class may also be declared static , which makes them class fields instead of instance fields. Each object that you instantiate in Java has its own copy of each instance field, but there is only one copy of a class field, which is shared by all instances of the class.
Fields and methods of a class may have different visibility levels, namely, public , protected , package , and private . These different levels allow fields and methods to be used in different ways.
Every class has a superclass. And from that superclass it inherits fields and methods. When a class inherits from another class, it is called a subclass of that class. This inheritance relationship forms what is known as a class hierarchy. The java.lang.Object class is the root class of all Java classes; Object is the ultimate superclass of all other classes in Java.
An interface is a Java construct that defines methods, like a class. However, it does not provide implementations for those methods. A class can implement an interface by defining an appropriate implementation for each of the methods in the interface. An interface expresses the methods an object can perform--what a class can do--while making no assumptions about how the object implements these methods.
When compiled, Java classes generate a class file that is a byte-coded representation of the class. When a Java program is run, these byte codes are interpreted and often compiled (with a Just-in-Time Compiler) into the native or machine code of the runtime environment and then executed. This is the part of the work done by the Java Virtual Machine (VM). These byte codes are platform-independent and can be executed on any platform that has a Java VM.
A method in a Java class can be declared to be a native method. A native method has no Java code; it assumes that the method is actually defined in a native library, typically in C. Native methods are used for a number of reasons: performance, access to native services provided by the operating system, and so on. In fact, many of the classes in the java.* packages contain native methods in order for the Java classes to intergrate with an existing operating system.
Part of the distribution of QuickTime for Java is a framework of classes. A package name (package and import) is a qualification that precedes the name of a class, i.e., it defines a name-space. The java.* packages are the standard set available on any distribution. QuickTime for Java uses quicktime.* to delineate the QuickTime for Java name-space.
| Previous | Chapter Top | Chapter Contents | Next |